﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Eksponent.RazorRocks
{
    public static class TemplateMatcherExtensions
    {

        public static TemplateMatcher<TItem>.ConfigSetter MatchIfHttpGet<TItem>(
            this TemplateMatcher<TItem>.ConfigSetter.MatchSetter matchSetter,
            params string[] templateNames)
            where TItem : class
        {          
            return
                matchSetter.MatchIf(
                    x =>
                    HttpContext.Current.Request.HttpMethod.Equals("get", StringComparison.InvariantCultureIgnoreCase),
                    templateNames);
        }

        public static TemplateMatcher<TItem>.ConfigSetter MatchIfHttpPost<TItem>(
            this TemplateMatcher<TItem>.ConfigSetter.MatchSetter matchSetter,
            params string[] templateNames)
            where TItem : class
        {
            return
                matchSetter.MatchIf(
                    x =>
                    HttpContext.Current.Request.HttpMethod.Equals("post", StringComparison.InvariantCultureIgnoreCase),
                    templateNames);
        }
    }
}
